package com.bjbn.controller;

import com.bjbn.dto.PvmcsEventRequest;
import com.bjbn.service.Webapi4PvmcsService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import reactor.core.publisher.Mono;

import java.util.Map;

/**
 * 大场景拼接及跑道防入侵系统API控制器
 *
 * @author bjbn
 */
@RestController
@RequestMapping("/CAN/Tr_PVMCS/runwayAntiIntrusion/V1api/v1")
@Tag(name = "大场景拼接及跑道防入侵系统API", description = "大场景拼接及跑道防入侵系统相关接口")
public class PvmcsController {
    @Autowired
    private Webapi4PvmcsService webapiService;

    /**
     * 获取入侵事件列表信息
     *
     * @param request 登录请求
     * @return 响应结果
     */
    @PostMapping("/getEventList")
    @Operation(summary = "获取入侵事件列表信息", description = "只可查询数最近90天的数据,请求并发量不能超过100次/秒")
    public Mono<ResponseEntity<Map<String, Object>>> getEventList(@RequestBody PvmcsEventRequest request) {
        return webapiService.pvmcsEventList(request)
                .map(ResponseEntity::ok)
                .defaultIfEmpty(ResponseEntity.noContent().build());
    }
}
